import unittest
from time import sleep

from ddt import ddt, data
from selenium import webdriver
from selenium.webdriver.common.by import By


@ddt
class Cases(unittest.TestCase):

    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.get("https://cn.bing.com/")

    def tearDown(self) -> None:
        self.driver.quit()

    @data('unittest', 'pytesr', '参数化')
    def test_01(self, words):
        self.driver.find_element(By.ID, "sb_form_q").send_keys(words)
        self.driver.find_element(By.ID, "search_icon").click()
        sleep(2)
        self.driver.save_screenshot(words + ".png")  # 搜索文本 命名
        sleep(1)


if __name__ == '__main__':
    unittest.main()